package com.lemon.rpcframe.dao.basedao;

import java.util.List;
import java.util.Map;

@SuppressWarnings("rawtypes")
public interface IDAO {

    /**
     * insert a entity
     * @param t
     * @return
     * @throws Exception
     */
    public Object insert(Object t) throws Exception;

    /**
     * update a entity
     * @param t
     * @throws Exception
     */
    public void upateEntity(Object t) throws Exception;

    /**
     * update a entity
     * @param t
     * @throws Exception
     */
    public <I> void upateByID(Class<?> clazz, String updateStatement, I id) throws Exception;

    /**
     * update column by custom
     * @param clazz
     * @param updateStatement
     * @param condition
     * @throws Exception
     */
    public void updateByCustom(Class<?> clazz, String updateStatement, String condition) throws Exception;

    /**
     * update column by custom
     * @param clazz
     * @param kv
     * @param query
     * @throws Exception
     */
    public void updateByCustom(Class<?> clazz, Map<String, Object> kv, Map<String, Object> condition) throws Exception;

    /**
     * delete record by id
     * @param <I>
     * @param clazz
     * @param id
     * @throws Exception
     */
    public <I> void deleteByID(Class<?> clazz, I id) throws Exception;

    /**
     * delete record by id array
     * @param <I>
     * @param clazz
     * @param id
     * @throws Exception
     */
    public <I> void deleteByIDS(Class<?> clazz, I[] ids) throws Exception;

    /**
     * delete by custom
     * @param clazz
     * @param condition
     * @throws Exception
     */
    public void deleteByCustom(Class<?> clazz, String condition) throws Exception;

    /**
     * delete by custom
     * @param clazz
     * @param condition
     * @throws Exception
     */
    public void deleteByCustom(Class<?> clazz, Map<String, Object> condition) throws Exception;

    /**
     * get entity
     * @param <I>
     * @param clazz
     * @param id
     * @return
     * @throws Exception
     */
    public <I> Object get(Class<?> clazz, I id) throws Exception;

    /**
     * get entity list by ids
     * @param <T>
     * @param <I>
     * @param clazz
     * @param ids
     * @return
     * @throws Exception
     */
    public <T, I> List<T> getListByIDS(Class<T> clazz, I[] ids) throws Exception;

    /**
     * get entity list by custom
     * @param clazz
     * @param columns
     * @param condition
     * @param orderBy
     * @return
     * @throws Exception
     */
    public List getListByCustom(Class<?> clazz, String columns, String condition, String orderBy) throws Exception;

    /**
     * get entity list by custom
     * @param clazz
     * @param columns
     * @param condition
     * @param orderBy
     * @return
     * @throws Exception
     */
    public <T> List<T> getListByCustom(Class<T> clazz, String columns, Map<String, Object> condition, String orderBy) throws Exception;

    /**
     * get entity list by page
     * @param clazz
     * @param condition
     * @param columns
     * @param page
     * @param pageSize
     * @param orderBy
     * @return
     * @throws Exception
     */
    public List getListByPage(Class<?> clazz, String condition, String columns, int page, int pageSize, String orderBy) throws Exception;

    /**
     * get entity list by page
     * @param clazz
     * @param condition
     * @param columns
     * @param page
     * @param pageSize
     * @param orderBy
     * @return
     * @throws Exception
     */
    public <T> List<T> getListByPage(Class<T> clazz, Map<String, Object> condition, String columns, int page, int pageSize, String orderBy) throws Exception;

    /**
     * get record count
     * @param clazz
     * @param condition
     * @return
     * @throws Exception
     */
    public int getCount(Class<?> clazz, String condition) throws Exception;

    /**
     * get record count
     * @param clazz
     * @param condition
     * @return
     * @throws Exception
     */
    public int getCount(Class<?> clazz, Map<String, Object> condition) throws Exception;

    /**
     * insert a entity
     * @param t
     * @param timeOut
     * @return
     * @throws Exception
     */
    public Object insert(Object t, int timeOut) throws Exception;

    /**
     * update a entity
     * @param t
     * @param timeOut
     * @throws Exception
     */
    public void upateEntity(Object t, int timeOut) throws Exception;

    /**
     * update a entity
     * @param t
     * @param timeOut
     * @throws Exception
     */
    public <I> void upateByID(Class<?> clazz, String updateStatement, I id, int timeOut) throws Exception;

    /**
     * update by custom
     * @param clazz
     * @param updateStatement
     * @param condition
     * @param timeOut
     * @throws Exception
     */
    public void updateByCustom(Class<?> clazz, String updateStatement, String condition, int timeOut) throws Exception;

    /**
     * update by custom
     * @param clazz
     * @param updateStatement
     * @param condition
     * @param timeOut
     * @throws Exception
     */
    public void updateByCustom(Class<?> clazz, Map<String, Object> kv, Map<String, Object> condition, int timeOut) throws Exception;

    /**
     * delete record by id
     * @param <I>
     * @param clazz
     * @param id
     * @param timeOut
     * @throws Exception
     */
    public <I> void deleteByID(Class<?> clazz, I id, int timeOut) throws Exception;

    /**
     * delete record by id array
     * @param <I>
     * @param clazz
     * @param id
     * @param timeOut
     * @throws Exception
     */
    public <I> void deleteByIDS(Class<?> clazz, I[] ids, int timeOut) throws Exception;

    /**
     * delete records by custom
     * @param clazz
     * @param condition
     * @param timeOut
     * @throws Exception
     */
    public void deleteByCustom(Class<?> clazz, String condition, int timeOut) throws Exception;

    /**
     * delete records by custom
     * @param clazz
     * @param condition
     * @param timeOut
     * @throws Exception
     */
    public void deleteByCustom(Class<?> clazz, Map<String, Object> condition, int timeOut) throws Exception;

    /**
     * get entity
     * @param <I>
     * @param clazz
     * @param id
     * @param timeOut
     * @return
     * @throws Exception
     */
    public <I> Object get(Class<?> clazz, I id, int timeOut) throws Exception;

    /**
     * get entity list by ids
     * @param <T>
     * @param <I>
     * @param clazz
     * @param ids
     * @param timeOut
     * @return
     * @throws Exception
     */
    public <T, I> List<T> getListByIDS(Class<T> clazz, I[] ids, int timeOut) throws Exception;

    /**
     * get entity list by custom
     * @param clazz
     * @param columns
     * @param condition
     * @param orderBy
     * @param timeOut
     * @return
     * @throws Exception
     */
    public List getListByCustom(Class<?> clazz, String columns, String condition, String orderBy, int timeOut) throws Exception;

    /**
     * get entity list by custom
     * @param clazz
     * @param columns
     * @param condition
     * @param orderBy
     * @param timeOut
     * @return
     * @throws Exception
     */
    public <T> List<T> getListByCustom(Class<T> clazz, String columns, Map<String, Object> condition, String orderBy, int timeOut) throws Exception;

    /**
     * get entity list by page
     * @param clazz
     * @param condition
     * @param columns
     * @param page
     * @param pageSize
     * @param orderBy
     * @param timeOut
     * @return
     * @throws Exception
     */
    public List getListByPage(Class<?> clazz, String condition, String columns, int page, int pageSize, String orderBy, int timeOut) throws Exception;

    /**
     * get entity list by page
     * @param clazz
     * @param condition
     * @param columns
     * @param page
     * @param pageSize
     * @param orderBy
     * @param timeOut
     * @return
     * @throws Exception
     */
    public <T> List<T> getListByPage(Class<T> clazz, Map<String, Object> condition, String columns, int page, int pageSize, String orderBy, int timeOut) throws Exception;

    /**
     * get record count
     * @param clazz
     * @param condition
     * @param timeOut
     * @return
     * @throws Exception
     */
    public int getCount(Class<?> clazz, String condition, int timeOut) throws Exception;

    /**
     * get record count
     * @param clazz
     * @param condition
     * @param timeOut
     * @return
     * @throws Exception
     */
    public int getCount(Class<?> clazz, Map<String, Object> condition, int timeOut) throws Exception;

    public <T> List<T> getListBySQL(Class<T> clazz, String sql, Object... param) throws Exception;

    public <T> List<T> getListBySQL(Class<T> clazz, String sql, int timeOut, Object... param) throws Exception;

    public int execBySQL(String sql, Object... param) throws Exception;

    public int execBySQL(String sql, int timeOut, Object... param) throws Exception;

    public int getCountBySQL(String sql, Object... param) throws Exception;

    public int getCountBySQL(String sql, int timeOut, Object... param) throws Exception;

    @Deprecated
    public List<Object[]> customSql(String sql, int columnCount) throws Exception;

    @Deprecated
    public void customSqlNoReturn(String sql) throws Exception;

    @Deprecated
    public List<Object[]> customSql(String sql, int columnCount, int timeOut) throws Exception;

    @Deprecated
    public void customSqlNoReturn(String sql, int timeOut) throws Exception;
}